<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions"  prefix="fn"%> 
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>组管理</title>
<script type="text/javascript">
	function addgroup(){
		window.location.href="addGroup";
	}
		
	
	function addmember(){
		var groupchooseId=document.getElementsByName("groupchoose");
		var groupchooseValue="";
		for(var i=0;i<groupchooseId.length;i++){
			if(groupchooseId[i].checked==true){
				groupchooseValue=groupchooseId[i].value;
				break;
			}
		}
		if(groupchooseValue==""){
			alert("请选择分组");
			return false;
		}
		window.location.href="addMember?addMember.GROUP_ID="+groupchooseValue;
	}
	
	
	function memberquery(){
		var groupchooseId=document.getElementsByName("groupchoose");
		var groupchooseValue="";
		for(var i=0;i<groupchooseId.length;i++){
			if(groupchooseId[i].checked==true){
				groupchooseValue=groupchooseId[i].value;
				break;
			}
		}
		if(groupchooseValue==""){
			alert("请选择分组");
			return false;
		}
		window.location.href="memberquery?addGroup.GROUP_ID="+groupchooseValue;
	}
	
	
	function memberedit(obj){
		window.location.href="memberedit?addMember.MEMBER_ID="+obj;
	}
	
	
	function deletemember(memberid,groupid){
		if(window.confirm("确定删除该条记录吗？")){
			window.location.href="deletemember?addMember.MEMBER_ID="+memberid+"&addMember.GROUP_ID="+groupid;
		}
		
		
	function back(){
		  	  window.location.href="groupIndex";  
		    }	
	}
	    
	    
	
</script>
</head>
<body>
<form action="" method="post" name="form1">
    <table>
    <tr>组管理</tr>
    <tr></tr>
    <tr></tr>
    <tr></tr>
        <tr>
            <td> <input type="button" value="创建分组" onclick="addgroup();"> </td>
            <td></td>
            <td></td>
            <td></td>
            <td><input type="button" value="单个导入" onclick="addmember();"></td>
            <td></td>
            <td></td>
            <td></td>
            <td><input type="button" value="查询" onclick="memberquery()"></td>
        </tr>    
    </table>
    
    <table>
    <tr>
    <td>
    	<c:forEach items="${obj.list}" var="groupList" varStatus="s">
    	<span><input type="radio" value="${groupList.GROUP_ID}" name="groupchoose"  <c:if test="${s.index==0 }">checked</c:if>>${groupList.GROUP_NAME} </span>
	    <c:if test="${s.index%5==4}">
	     <br>
	    </c:if>
	</c:forEach>
	</td>	
    </tr>
    </table>
    
   <c:if test="${fn:length(obj.memberlist)>0}">
   <div>
   <table width="50%" border="1">
    <tr>
        <th>姓名</th>
        <th>邮箱</th>
        <th>手机号码</th>
        <th>操作</th>
    </tr>   
    <c:forEach items="${obj.memberlist}" var="memberList" varStatus="s">
		<tr>
			<td>${memberList.MEMBER_NAME}</td>
			<td>${memberList.MEMBER_EMAIL}</td>
			<td>${memberList.MEMBER_PHONE}</td>
			<td>
				<input type="button" value="编辑" onclick="memberedit('${memberList.MEMBER_ID}')">
				<input type="button" value="删除" onclick="deletemember('${memberList.MEMBER_ID}','${memberList.GROUP_ID}')">

			</td>

		</tr>
	</c:forEach>
	<tr align="center">
		<td colspan="4" ><input type="button" value="返回" onclick="back();"> </td>
	</tr>
    </table>
 </div>
 </c:if>
    
    

       
</form>
</body>
</html>